package com.rchat.pocmini.channel;

import android.content.Context;

import com.airtalkee.sdk.OnChannelAlertListener;
import com.airtalkee.sdk.OnChannelListener;
import com.airtalkee.sdk.entity.AirChannel;
import com.airtalkee.sdk.entity.AirContact;
import com.baoyz.swipemenulistview.SwipeMenuListView;
import com.rchat.pocmini.activity.bean.GroupBean;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * Created by ljd on 2017/2/7.
 * <p>
 * OnChannelListener 接口实现类，返回与频道数据列表相关的事件
 * OnChannelAlertListener 接口实现类，返回与频道呼入请求相关的事件
 */

public class PocAirtalkeeChannelListener implements OnChannelListener, OnChannelAlertListener {

    private SwipeMenuListView groupListView;
    private Context context;
    private ArrayList<GroupBean> data;

    //================ OnChannelListener方法 ===============//

    /**
     * 频道列表返回事件
     *
     * @param isOk        网络操作是否成功
     * @param channelList 频道列表
     */
    @Override
    public void onChannelListGet(boolean isOk, List<AirChannel> channelList) {
//        Log.e("onChannelListGet","isOk:" + isOk + "," + "channelList:" + channelList);
//        data = new ArrayList<>();
//        for (AirChannel airChannel:channelList){
//            GroupBean bean = new GroupBean();
//            bean.setGroupName(airChannel.getDisplayName());
//            bean.setGroupId(airChannel.getId());
//            bean.setMemberTotalCount(airChannel.getMemberCount() + "");
//            bean.setMemberOnlineCount(airChannel.getOnlineNumber() + "");
//            data.add(bean);
//            Log.e("AirChannel name",airChannel.getDisplayName());
//            Log.e("AirChannel id",airChannel.getId());
//        }
//
//        adapter = new GroupListViewAdapter(context,data);
//        groupListView.setAdapter(adapter);
//        Log.e("groupData",data.toString());

    }

    /**
     * 频道成员列表返回事件
     *
     * @param channelId  调用时指定的频道ID
     * @param memberList 频道内所有成员
     */
    @Override
    public void onChannelMemberListGet(String channelId, List<AirContact> memberList) {
    }

    /**
     * 频道在线人数列表返回事件
     *
     * @param onLineMemberList 返回所有频道在线人数的列表，其中：
     *                         String 表示频道ID
     *                         Integer 表示对应频道的在线人数
     */
    @Override
    public void onChannelOnlineCount(LinkedHashMap<String, Integer> onLineMemberList) {
    }


    @Override
    public void onChannelPersonalCreateNotify(AirChannel airChannel) {
    }

    @Override
    public void onChannelPersonalDeleteNotify(AirChannel airChannel) {
    }

    @Override
    public void onChannelMemberAppendNotify(AirChannel airChannel, List<AirContact> contactList) {
    }

    @Override
    public void onChannelMemberDeleteNotify(AirChannel airChannel, List<AirContact> contactList) {

    }

    @Override
    public void onChannelMemberUpdateNotify(AirChannel airChannel, List<AirContact> contactList) {
    }

    @Override
    public void onChannelMemberUpdateNotify(AirChannel airChannel, AirContact airContact) {

    }

    //================ OnChannelAlertListener方法 ===============//

    /**
     * 发送频道呼入请求返回事件
     *
     * @param isOk 请求是否发送成功
     */
    @Override
    public void onChannelAlertSent(boolean isOk) {
    }

    /**
     * 接收到呼入请求通知事件（其他成员发送频道呼入请求，SDK接收到此呼入请求通知事件）
     *
     * @param airChannel   呼入请求的频道实例
     * @param airContact   呼入请求的用户
     * @param isAcceptCall 是否SDK已自动接受此呼入请求，即当呼入请求方以强制呼入的方式发起
     */
    @Override
    public void onChannelAlertIncomingStart(AirChannel airChannel, AirContact airContact, boolean isAcceptCall) {
    }

    /**
     * 发送频道呼入请求返回事件（呼入请求通知一直无应答而超市，则返回此事件）
     */
    @Override
    public void onChannelAlertIncomingStop() {
    }


    public void setContext(Context context) {
        this.context = context;
    }

    public void setGroupListView(SwipeMenuListView groupListView) {
        this.groupListView = groupListView;
    }


}
